package com.kbot.bot.Script;

import com.kbot.bot.Constants;

import java.io.File;
import java.util.List;
import java.util.LinkedList;

/**
 * Created by IntelliJ IDEA.
 * User: Jan Ove
 * Date: 30.jan.2009
 * Time: 19:55:06
 * To change this template use File | Settings | File Templates.
 */
public class Script {
    private static List<Script> scripts = new LinkedList<Script>();

    static {
		File directory = new File(Constants.DIRECTORY_SCRIPTS);
		for(File file : directory.listFiles()) {
			if(!file.getName().equals("Transformer.class")) {
				String name = file.getName().replaceAll(".class", "");
				try {
					Script transformer = (Script) Class.forName(Constants.PACKAGE_SCRIPTS + "." + name).newInstance();
					if(Script.class.isAssignableFrom(transformer.getClass())) {
						scripts.add(transformer);
					}
				} catch(InstantiationException e) {
					e.printStackTrace();
				} catch(IllegalAccessException e) {
					e.printStackTrace();
				} catch(ClassNotFoundException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
